package com.sky.business.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.business.sys.domain.Container;
import com.sky.business.sys.mapper.ContainerMapper;
import com.sky.business.sys.service.ContainerService;
import com.sky.common.enums.TaskType;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container> implements ContainerService{


    @Override
    public List<Container> findByNode(Integer nodeId) {
        LambdaQueryWrapper<Container> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Container::getNodeId,nodeId);
        queryWrapper.eq(Container::getIsDel,false);
        return getBaseMapper().selectList(queryWrapper);
    }

    @Override
    public List<Container> findByNodeAndTaskType(Integer nodeId, TaskType taskType) {
        LambdaQueryWrapper<Container> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Container::getNodeId,nodeId);
        queryWrapper.eq(Container::getTaskType,taskType);
        queryWrapper.eq(Container::getIsDel,false);
        return getBaseMapper().selectList(queryWrapper);
    }

    @Override
    public List<Container> findByCameraIdAndTaskType(Long cameraConfigId, TaskType taskType) {
        LambdaQueryWrapper<Container> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Container::getCameraConfigId,cameraConfigId);
        queryWrapper.eq(Container::getTaskType,taskType);
        queryWrapper.eq(Container::getIsDel,false);
        return getBaseMapper().selectList(queryWrapper);
    }

    @Override
    public List<Container> findByCameraIdAndTaskTypeIn(Long cameraConfigId, List<TaskType> taskTypeList) {
        LambdaQueryWrapper<Container> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Container::getCameraConfigId,cameraConfigId);
        queryWrapper.in(Container::getTaskType,taskTypeList);
        queryWrapper.eq(Container::getIsDel,false);
        return getBaseMapper().selectList(queryWrapper);
    }


}
